package com.promis.fastdfs;

public class StorageClientFactory {

    private static TrackerServer trackerServer;
    private static StorageClient storageClient;

    public static StorageClient build() {
        try {
            if (trackerServer == null || storageClient == null
                    || !trackerServer.getSocket().isConnected() || trackerServer.getSocket().isClosed()) {
                TrackerClient tracker = new TrackerClient();
                trackerServer = tracker.getConnection();
                storageClient = new StorageClient(trackerServer, null);
            }
            return storageClient;
        } catch (Exception ex) {
            ex.printStackTrace();
            return null;
        }
    }
}
